package com.sc.byahi.user.client.components.maps;

import com.google.gwt.ajaxloader.client.Properties;
import com.google.gwt.ajaxloader.client.Properties.TypeException;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.event.shared.GwtEvent;

public class MDragEndEvent extends GwtEvent<MDragEndHandler> {

	public static Type<MDragEndHandler> TYPE = new Type<MDragEndHandler>();
	protected Properties properties;

	public MDragEndEvent(Properties properties) {
		this.properties = properties;
	}

	public Properties getProperties() {
		return properties;
	}

	public LatLng getLatLng() {
		LatLng latLng = null;
		try {
			latLng = (LatLng) properties.getObject("latLng");
		} catch (TypeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return latLng;
	}

	protected native String getAsJson(JavaScriptObject jso) /*-{
		return jso.toSource ? jso.toSource() : "NO SOURCE";
	}-*/;

	@Override
	public Type<MDragEndHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(MDragEndHandler handler) {
		handler.onEvent(this);
	}

}